#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

int main()
{
    int arr[50] = { 0 }, num,count=0,front=0;
    for (int i = 0; i < 10; i++)
    {
        scanf("%d", &num);
        if (count == 0)
        {
            arr[front] = num;
            count++;
        }
        else
        {
            int flag = 0;
            for (int j = front%50; j < (((front+count)>=50)?((front+count)%50):(front+count)); j++)
            {
                if (arr[j] == num)
                {
                    arr[front] = 0;
                    front++;
                    count--;
                    flag = 1;
                    break;
                }
            }
            if (flag == 0)
            {
                arr[(front + count)%50] = num;
                count++;
            }
        }
    }
    for (int i = front%50; i < (((front + count) >= 50) ? ((front + count) % 50) : (front + count)); i++)
    {
        printf("%d ", arr[i % 50]);
    }
    return 0;
}